package gui;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;

/**
 * File Menu
 * @author vincenzo.delia@polito.it
 *
 */
@SuppressWarnings("serial")
public class FileMenu extends HcsGuiMenu {
	
	private CommandMenuBar commandMenuBar;
	private LogViewer logViewer;

	public ActionListener ExitOnClose = new ActionListener() {

		public void actionPerformed(ActionEvent e) {
			MainFrame mainFrame = getCommandMenuBar().getMainFrame();
			mainFrame.dispatchEvent(new WindowEvent(mainFrame, WindowEvent.WINDOW_CLOSING));
		}
		
	};
	
	public ActionListener ShowLogger = new ActionListener() {

		public void actionPerformed(ActionEvent e) {
			logViewer.setVisible(true);
		}
	};
	
	public FileMenu(CommandMenuBar commandMenuBar) {
		super("File");
		this.commandMenuBar = commandMenuBar;
		this.setMnemonic(KeyEvent.VK_F);
		this.logViewer = new LogViewer(this);
		GuiUtilities.fitMenuItem(this,"Show Logger",ShowLogger, true,KeyEvent.VK_L);
		this.addSeparator();
		GuiUtilities.fitMenuItem(this,"Quit", ExitOnClose, true,KeyEvent.VK_Q);
	}
	

	public CommandMenuBar getCommandMenuBar() {
		return this.commandMenuBar;
	}
}
